package com.vcredit.creditcat.service;

import com.vcredit.creditcat.model.ClickLog;
import com.vcredit.framework.bean.MsgBean;
import com.vcredit.framework.kafka.KafKaProcess;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


/**
 * Created by liaoshengjun on 2017/7/25.
 */
@Service
public class ClickLogConsumerService implements KafKaProcess {
	@Autowired
	private ClickLogService clickLogService;
	@Override
	public void process(MsgBean msgBean) {
		if (msgBean != null) {
			Object clickLogData = msgBean.get("clickLogData");
			Object custId=msgBean.get("custId");
			Object logType=msgBean.get("logType");
			if(clickLogData!=null){
				ClickLog clicklog=new ClickLog();
				clicklog.setClickLogData(clickLogData.toString());
				if (custId!=null){
					clicklog.setCustId(Long.valueOf(custId.toString()));
				}
				if(logType!=null){
					clicklog.setLogType(Integer.valueOf(logType.toString()));
				}
				clickLogService.insert(clicklog);
			}
		}
	}
}
